<template>
<div>
  <van-button @click="get_fund()">固定收益</van-button>
  <van-button @click="get_fund2()">实时基金</van-button>
  <van-button @click="get_fund3()">按天收益</van-button>
  <el-table
      :data="list"
      stripe
      style="width: 100%;height:100%">
    <el-table-column
        prop="name"
        label="名称">
    </el-table-column>
    <el-table-column
        prop="model"
        label="型号"
    >
    </el-table-column>
    <el-table-column
        prop="stating_amount"
        label="起步资金"
    >
    </el-table-column>
    <el-table-column
        prop="interest_rate"
        label="利率">
    </el-table-column>
    <el-table-column
        prop="money"
        label="我的金额">
    </el-table-column>
    <!--      <el-table-column-->
    <!--          prop="time_state"-->
    <!--          label="时间">-->
    <!--      </el-table-column>-->
    <el-table-column fixed="right" label="操作" width="120">
      <template v-slot="scope">
        <!--        <el-button type="text" size="small" @click="handleClick(scope.row.id)"-->
        <!--        >通过</el-button-->
        <!--        >-->
        <!--        <el-button type="text" size="small" @click="refuse(scope.row.id)">拒绝</el-button>-->
        <el-button type="text" size="small" @click="Order_details(scope.row.id)">卖出</el-button>
        <el-button type="text" size="small" @click="orders(scope.row.id)">再次买入</el-button>
      </template>
    </el-table-column>
  </el-table>
  <van-popup v-model:show="show" style="width: 300px; height: 70%" closeable close-icon="close">
    <div style="height: 20%"></div>
    <van-field label="输入卖出金额" v-model="price"></van-field>
    <center>
      <van-button>取消</van-button>
      <van-button @click="queding">确定</van-button>
    </center>
  </van-popup>
</div>
</template>

<script>
export default {
name: "my_fund",
  data(){
  return{
    list: [],
    nuid:'1',
    userid:localStorage.getItem('usrid'),
    price:'',
    show:false,
    nu_di:''
  }
  },
  methods:{
    queding(){
      this.myaxios('http://localhost:8000/sell_out/', 'post', {'price':this.price,'nu_di':this.nu_di})
          .then(res => {
            // this.list = res.list

            console.log(res)
            if (res.code=='200'){
              this.show=false
            }
          })
    },
    Order_details(id){
      this.show=true
      this.nu_di=id
    },
    get_fund(){
      this.nuid='1'
      this.get_role()
    }, get_fund2(){
      this.nuid='2'
      this.get_role()
    }, get_fund3(){
      this.nuid='3'
      this.get_role()
    },
    get_role() {
      this.myaxios('http://localhost:8000/my_fund_get/', 'post', {'userid':this.userid,'nuid':this.nuid})
          .then(res => {
            // this.list = res.list
            this.list=res.list
            console.log(this.list)
          })
    },
  },
  mounted() {
  this.get_role()
  }
}
</script>

<style scoped>

</style>
